package com.bluemsun.naturallanguageprocessing.exceptionHandler;

import com.bluemsun.naturallanguageprocessing.common.ServerResponse;
import com.bluemsun.naturallanguageprocessing.exception.good.UserDoGoodException;
import com.bluemsun.naturallanguageprocessing.exception.good.UserUnDoGoodException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author hucl
 * @describe 用户点赞异常处理器
 */
@RestControllerAdvice
public class UserGoodExceptionHandler {

    private static final Logger logger = LoggerFactory.getLogger(UserGoodExceptionHandler.class);

    @ExceptionHandler(UserDoGoodException.class)
    public ServerResponse userDoGoodException(UserDoGoodException e){
        logger.error("error:{}",e.getMessage(),e);
        return ServerResponse.createByErrorMessage(e.getMessage());
    }

    @ExceptionHandler(UserUnDoGoodException.class)
    public ServerResponse userUnDoGoodException(UserUnDoGoodException e){
        logger.error("error:{}",e.getMessage(),e);
        return ServerResponse.createByErrorMessage(e.getMessage());
    }
}
